@font-face {font-family: 'Manrope'; src: url(assets/manrope.woff2) format('woff2'); font-weight: 200 800; font-display: swap;}
@font-face {font-family: 'DM Sans'; src: url(assets/dm-sans.woff2) format('woff2'); font-weight: 100 1000; font-display: swap;}

:root {
  --blue: #0a72b9;
  --blue-dark: #085e98;
  --ink: #17364b;
  --muted: #597285;
  --canvas: #f7f9fb;
  --surface: #ffffff;
  --border: #dce6ed;
  --accent: #f5e425;
  --ok: #1f8a5b;
  --warn: #9a6200;
  --error: #b42335;
  --shadow: 0 8px 24px rgba(23, 54, 75, .1);
  --panel: 440px;
  color-scheme: light;
}
* {box-sizing: border-box;}
html, body {margin: 0; height: 100%;}
body {font: 16px/1.5 'DM Sans', system-ui, sans-serif; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased;}
h1, h2, h3 {font-family: 'Manrope', system-ui, sans-serif; margin: 0; text-wrap: balance;}
button, input, select, textarea {font: inherit; color: inherit;}
[hidden] {display: none !important;}
.oculto {position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);}
:focus-visible {outline: 2px solid var(--blue); outline-offset: 2px;}

.boton {min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;}
.boton:hover {border-color: #bfd0dc;}
.boton.principal {background: var(--blue); border-color: var(--blue); color: #fff;}
.boton.principal:hover {background: var(--blue-dark);}
.boton:disabled {opacity: .55; cursor: default;}
.boton.chico {min-height: 36px; padding: 0 12px; font-size: 14px;}
.boton svg {width: 20px; height: 20px;}
.campo {display: grid; gap: 4px; flex: 1;}
.campo > span {font-size: 14px; font-weight: 600; color: var(--muted);}
.campo input, .campo select, .campo textarea {width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff;}
.campo textarea {resize: vertical; line-height: 1.4;}
.error-texto {color: var(--error); font-size: 14px; margin: 0; min-height: 1.2em;}

/* Login */
.login {min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 30% 10%, #e3f0f9, var(--canvas) 60%);}
.tarjeta-login {width: min(380px, 100%); display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 24px; box-shadow: var(--shadow); text-align: center;}
.tarjeta-login img {margin: 0 auto; height: auto;}
.tarjeta-login h1 {font-size: 28px;}
.tarjeta-login p {margin: 0; color: var(--muted);}
.tarjeta-login .campo {text-align: left;}

/* App */
.app {height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel); grid-template-rows: 64px 1fr; grid-template-areas: 'barra barra' 'escena panel';}
.barra {grid-area: barra; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 3;}
.marca {display: flex; align-items: center; gap: 10px; min-width: 0; font-family: 'Manrope', sans-serif; font-size: 18px; white-space: nowrap;}
.marca img {height: 33px; width: auto;}
.marca span {overflow: hidden; text-overflow: ellipsis;}
.acciones {display: flex; gap: 8px; flex: none;}
.escena {grid-area: escena; position: relative; overflow: hidden; min-height: 0; touch-action: none;}
.escena canvas {display: block;}
.etiquetas {position: absolute; inset: 0; pointer-events: none;}
.conexion {position: absolute; top: 12px; left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; z-index: 2;}

.cartel-sala {pointer-events: auto; cursor: pointer; border: 0; padding: 6px 14px 6px 10px; border-radius: 999px; background: rgba(255,255,255,.94); box-shadow: 0 4px 14px rgba(23,54,75,.14); font: 700 15px 'Manrope', sans-serif; color: var(--ink); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; min-height: 36px;}
.cartel-sala::before {content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--color);}
.cartel-sala.activa {background: var(--ink); color: #fff;}
.nombre-persona {pointer-events: auto; cursor: pointer; border: 0; padding: 2px 10px; border-radius: 999px; background: rgba(23,54,75,.82); color: #fff; font: 600 13px 'DM Sans', sans-serif; white-space: nowrap; min-height: 26px;}
.cartel-empresa {font: 800 16px 'Manrope', sans-serif; color: var(--blue); background: #fff; padding: 2px 10px; border-radius: 8px; box-shadow: 0 2px 8px rgba(23,54,75,.12); white-space: nowrap;}
.burbuja {display: flex; align-items: center; gap: 3px; padding: 6px 12px; background: #fff; border-radius: 14px 14px 14px 4px; box-shadow: 0 6px 16px rgba(23,54,75,.18); font-size: 13px; font-weight: 600; white-space: nowrap; transform: translateY(-50%);}
.burbuja span {margin-right: 4px;}
.burbuja i, .puntos i {width: 5px; height: 5px; border-radius: 50%; background: var(--blue); display: inline-block; animation: punto 1.2s infinite ease-in-out;}
.burbuja i:nth-of-type(2), .puntos i:nth-child(2) {animation-delay: .15s;}
.burbuja i:nth-of-type(3), .puntos i:nth-child(3) {animation-delay: .3s;}
.burbuja[data-estado=buscando] i {background: var(--ok);}
@keyframes punto {0%, 80%, 100% {transform: translateY(0); opacity: .4;} 40% {transform: translateY(-4px); opacity: 1;}}

/* Panel */
.panel {grid-area: panel; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--border);}
.panel-cab {display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border);}
.panel-titulos {flex: 1; min-width: 0;}
.panel-titulos h2 {font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.panel-titulos p {margin: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.panel-titulos p.activo {color: var(--blue); font-weight: 600;}
.volver {width: 44px; height: 44px; margin-left: -8px; border: 0; background: none; border-radius: 12px; cursor: pointer; display: grid; place-items: center;}
.volver svg {width: 24px; height: 24px;}
.avatar {--color: var(--blue); flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--color); color: #fff; display: grid; place-items: center; font: 800 14px 'Manrope', sans-serif;}
.avatar.grande {width: 44px; height: 44px; font-size: 18px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--color) 22%, transparent);}
.pestanas {display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--border); overflow-x: auto;}
.pestanas button {border: 0; background: none; padding: 8px 12px; min-height: 44px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;}
.pestanas button[aria-selected=true] {color: var(--ink); border-color: var(--blue);}
.aviso-central {margin: 8px 16px 0; min-height: 40px; border: 0; border-radius: 12px; background: #e6f1f9; color: var(--blue-dark); font-weight: 600; cursor: pointer;}

.mensajes {flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain;}
#parcial {display: contents;}
.msg {max-width: 100%; margin: 0;}
.msg time {font-size: 12px; color: var(--muted); font-weight: 400;}
.msg header {font-size: 14px; margin-bottom: 4px; display: flex; gap: 8px; align-items: baseline;}
.msg header b {color: color-mix(in srgb, var(--color) 75%, var(--ink));}
.msg.mio {align-self: flex-end; max-width: 85%; background: var(--blue); color: #fff; padding: 10px 14px; border-radius: 16px 16px 4px 16px;}
.msg.mio time {color: rgba(255,255,255,.8); display: block; text-align: right;}
.msg.mio p {margin: 0;}
.msg.suyo, .msg.pedido-recibido {align-self: flex-start; max-width: 92%; background: var(--canvas); border: 1px solid var(--border); padding: 10px 14px; border-radius: 16px 16px 16px 4px;}
.msg.pedido-recibido {border-left: 4px solid var(--color);}
.msg.escribiendo {border-style: dashed;}
.msg.pase {align-self: stretch; font-size: 14px; color: var(--muted); border-radius: 12px; padding: 0;}
.msg.pase summary {cursor: pointer; padding: 6px 4px; list-style: none; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap;}
.msg.pase summary::-webkit-details-marker, .msg.respuesta summary::-webkit-details-marker {display: none;}
.msg.pase b {color: var(--ink);}
.msg.pase .flecha {color: var(--color); font-weight: 800;}
.msg.pase .vista {flex-basis: 100%; padding-left: 20px; font-style: italic;}
.msg.pase[open] .vista {display: none;}
.msg.pase > .md {margin: 0 0 4px 20px; padding: 8px 12px; border-left: 3px solid var(--color); background: var(--canvas); border-radius: 0 8px 8px 0; color: var(--ink);}
.msg.respuesta {align-self: stretch; border: 1px solid var(--border); border-left: 4px solid var(--color); border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(23,54,75,.05);}
.msg.respuesta summary {cursor: pointer; list-style: none; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 10px 12px; font-size: 14px;}
.msg.respuesta summary .vista {display: block; color: var(--muted); margin-top: 2px;}
.msg.respuesta summary .abrir {grid-column: 2; color: var(--blue); font-weight: 600;}
.msg.respuesta[open] summary .vista {display: none;}
.msg.respuesta[open] summary .abrir {display: none;}
.msg.respuesta > .md {padding: 0 14px 12px;}
.msg.error {align-self: stretch; padding: 10px 14px; border-radius: 12px; background: #fdecee; color: var(--error); font-size: 14px; font-weight: 600;}
.trabajando {margin: 0; align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--color) 10%, #fff);}
.trabajando b {color: var(--ink);}
.puntos {display: inline-flex; gap: 3px;}
.puntos i {background: var(--color);}

.md {overflow-wrap: anywhere;}
.md > :first-child {margin-top: 0;}
.md > :last-child {margin-bottom: 0;}
.md p, .md ul, .md ol {margin: 0 0 8px;}
.md ul, .md ol {padding-left: 22px;}
.md li {margin: 2px 0;}
.md .titulo {font-family: 'Manrope', sans-serif; font-weight: 800; margin-top: 12px;}
.md .titulo.t1 {font-size: 20px;}
.md .titulo.t2 {font-size: 18px;}
.md code {font: 14px ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: rgba(23,54,75,.07); padding: 1px 4px; border-radius: 4px;}
.md a {color: var(--blue);}
.msg.mio .md a {color: #fff;}
.md hr {border: 0; border-top: 1px solid var(--border); margin: 12px 0;}
.codigo {margin: 8px 0; border-radius: 12px; overflow: hidden; background: #14232f; color: #e6edf3;}
.codigo-cab {display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 12px; font-size: 12px; color: #9fb3c2; background: #1b2e3c;}
.codigo-cab .copiar {border: 0; background: none; color: #cfe3f2; font-size: 13px; font-weight: 600; min-height: 32px; padding: 0 10px; border-radius: 8px; cursor: pointer;}
.codigo-cab .copiar:hover {background: rgba(255,255,255,.08);}
.codigo pre {margin: 0; padding: 12px; overflow-x: auto; max-height: 420px;}
.codigo code {background: none; padding: 0; color: inherit; font-size: 13px; line-height: 1.5;}
.dibujo {margin: 8px 0; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; text-align: center;}
.dibujo img {max-width: 100%; max-height: 360px;}

.vacio {margin: auto 0; display: grid; gap: 8px; color: var(--muted);}
.vacio p {margin: 0;}
.vacio-titulo {font: 800 22px 'Manrope', sans-serif; color: var(--ink);}
.ejemplo {text-align: left; border: 1px solid var(--border); background: var(--canvas); border-radius: 12px; padding: 10px 14px; min-height: 44px; cursor: pointer; color: var(--ink);}
.ejemplo:hover {border-color: var(--blue);}

.solo-lectura {margin: 0; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); background: var(--canvas);}
.solo-lectura button {border: 0; background: none; padding: 0; color: var(--blue); font-weight: 600; text-decoration: underline; cursor: pointer;}
.enviar {padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border);}
.pendientes {margin: 0 4px 6px; font-size: 13px; color: var(--muted);}
.pendientes:empty {display: none;}
.caja-envio {display: flex; gap: 8px; align-items: flex-end;}
.caja-envio textarea {flex: 1; min-height: 44px; max-height: 180px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; resize: none; line-height: 1.4; background: var(--canvas);}
.caja-envio textarea:focus {background: #fff;}
#enviarBtn {width: 44px; padding: 0;}

/* Team editor */
.dialogo {width: min(720px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 24px 64px rgba(23,54,75,.25);}
.dialogo::backdrop {background: rgba(23,54,75,.4);}
.dialogo form {display: flex; flex-direction: column; max-height: calc(100dvh - 32px);}
.dialogo-cab {padding: 20px 24px 12px; border-bottom: 1px solid var(--border);}
.dialogo-cab h2 {font-size: 22px;}
.dialogo-cab p {margin: 4px 0 0; color: var(--muted); font-size: 14px;}
.dialogo-cuerpo {overflow-y: auto; padding: 16px 24px; display: grid; gap: 12px;}
.dialogo-cuerpo h3 {font-size: 18px; margin-top: 8px;}
.dialogo-cuerpo > .boton {justify-self: start;}
.dialogo-pie {display: flex; gap: 8px; align-items: center; padding: 12px 24px; border-top: 1px solid var(--border);}
.dialogo-pie .error-texto {flex: 1;}
.ficha {margin: 0 0 12px; padding: 12px; border: 1px solid var(--border); border-left: 4px solid var(--color, var(--border)); border-radius: 12px; display: grid; gap: 10px; min-width: 0;}
.fila {display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;}
.fila .campo {min-width: 160px;}
.quitar {min-height: 44px; padding: 0 12px; border: 1px solid #f1c6cc; background: #fff; color: var(--error); border-radius: 12px; font-weight: 600; cursor: pointer;}
.colores {display: flex; gap: 6px; flex-wrap: wrap;}
.color input {position: absolute; opacity: 0;}
.color span {display: block; width: 32px; height: 32px; border-radius: 50%; background: var(--color); cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--border);}
.color input:checked + span {box-shadow: 0 0 0 2px var(--ink);}
.color input:focus-visible + span {outline: 2px solid var(--blue); outline-offset: 2px;}

.aviso {position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); margin: 0; padding: 10px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow); z-index: 10; max-width: calc(100% - 32px);}

/* Phone and narrow screens: the building on top, the chat below. */
@media (max-width: 820px) {
  .app {grid-template-columns: minmax(0, 1fr); grid-template-rows: 56px 38dvh 1fr; grid-template-areas: 'barra' 'escena' 'panel';}
  body.viendo-oficina .app {grid-template-rows: 56px 30dvh 1fr;}
  .barra {padding: 0 8px 0 12px;}
  .marca {font-size: 16px;}
  .marca img {height: 26px;}
  .marca .sub {display: none;}
  .acciones .boton {padding: 0 10px; font-size: 14px;}
  #verTodoBtn {display: none;}
  .panel {border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; margin-top: -12px; z-index: 2; box-shadow: 0 -8px 24px rgba(23,54,75,.08);}
  .cartel-sala {font-size: 13px; padding: 4px 10px 4px 8px; min-height: 30px;}
  .nombre-persona {font-size: 12px;}
  .burbuja {font-size: 12px; padding: 4px 10px;}
  .dialogo {width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; max-width: none;}
  .dialogo form {max-height: 100dvh; height: 100%;}
  .dialogo-cuerpo {flex: 1;}
}
@media (max-width: 360px) {
  .marca > span {display: none;}
}
@media (prefers-reduced-motion: reduce) {
  .burbuja i, .puntos i {animation: none; opacity: .8;}
}

.notas summary {cursor: pointer; font-size: 14px; font-weight: 600; color: var(--blue); min-height: 32px; display: flex; align-items: center;}
.notas ul {margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 4px;}
.notas li {display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 14px; padding: 6px 8px; background: var(--canvas); border-radius: 8px;}
.notas .olvidar {flex: none; border: 0; background: none; color: var(--error); font-weight: 600; cursor: pointer; min-height: 32px; padding: 0 8px; border-radius: 8px;}
.sin-notas {margin: 0; font-size: 14px; color: var(--muted);}
