:root {
  color-scheme: dark;
  --bg: #0a0a0b; --bg-2: #0f0f11; --panel: #131315; --panel-2: #1a1a1d;
  --line: rgba(255, 255, 255, .09); --line-2: rgba(255, 255, 255, .18);
  --text: #f4f3ef; --soft: #c9c8c2; --muted: #93928c; --dim: #6a6964;
  --accent: #e8b48a; --ok: #8fd9b0;
  --marca: #6fd3c1; /* color del ambiente; lo cambia demo.js */
  --sans: "Geist", "Segoe UI", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 22px; border-radius: 999px; border: 1px solid transparent; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .2s, border-color .2s; }
.btn-sm { padding: 8px 15px; font-size: 14px; }
.btn-icon { padding: 8px 12px; }
.btn-white { background: var(--text); color: var(--bg); }
.btn-white:hover { background: #fff; }
.btn-ghost { border-color: var(--line-2); background: transparent; }
.btn-ghost:hover, .btn-ghost[aria-pressed="true"] { background: rgba(255, 255, 255, .08); }
.btn-ghost[aria-pressed="true"] { border-color: var(--marca); color: var(--marca); }
.link-btn { background: none; border: 0; padding: 0; margin-left: 14px; color: var(--text); text-decoration: underline; cursor: pointer; }
.mono-label { font: 400 11.5px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.fine { font-size: 13px; color: var(--dim); }

/* Barra superior */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: rgba(10, 10, 11, .86); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font: 500 18px/1 var(--sans); letter-spacing: -.03em; }
.logo svg { width: 30px; height: 21px; }
.logo em { font-style: normal; font-weight: 400; color: var(--muted); }
.top-title { font: 400 11.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line-2); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.custom-bar { padding: 10px 22px; font-size: 14px; color: var(--soft); background: color-mix(in srgb, var(--marca) 12%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--marca) 35%, transparent); }
.custom-bar strong { color: var(--marca); font-weight: 500; }

/* Distribución */
.studio { display: grid; grid-template-columns: 250px minmax(0, 1fr) 360px; min-height: calc(100vh - 58px); }
.giros { position: relative; border-right: 1px solid var(--line); padding: 14px 12px; display: grid; gap: 2px; align-content: start; }
.giro { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; text-align: left; background: none; border: 0; border-radius: 12px; padding: 10px 12px; cursor: pointer; color: var(--soft); font-size: 14.5px; transition: background .2s; }
.giro i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: .55; }
.giro small { font: 400 11.5px var(--mono); color: var(--dim); }
.giro:hover { background: rgba(255, 255, 255, .04); }
.giro.is-on { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line) inset; }
.giro.is-on i { opacity: 1; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); }

/* Escenario: lo que ve el cliente */
.stage { position: relative; padding: 28px 24px 36px; display: flex; flex-direction: column; align-items: center; gap: 16px; overflow: hidden; }
.stage::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(520px 420px at 50% 46%, color-mix(in srgb, var(--marca) 13%, transparent), transparent 70%); transition: background .4s; }
.stage > * { position: relative; }
.stage-head { text-align: center; display: grid; gap: 8px; justify-items: center; }
.stage-head h1 { font: 300 clamp(28px, 3.4vw, 44px)/1.05 var(--sans); letter-spacing: -.04em; text-wrap: balance; }
.casos { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.caso { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 8px 16px; font-size: 14px; color: var(--soft); cursor: pointer; transition: background .2s, border-color .2s, color .2s; }
.caso:hover { background: rgba(255, 255, 255, .05); }
.caso.is-on { background: var(--marca); border-color: var(--marca); color: #0a0a0b; font-weight: 500; }

/* Teléfono */
.device { width: min(390px, 100%); height: clamp(440px, calc(100vh - 350px), 640px); display: flex; flex-direction: column; background: #0c0c0e; border: 1px solid var(--line-2); border-radius: 38px; overflow: hidden; box-shadow: 0 50px 120px -50px #000, 0 0 0 8px #111113, 0 0 0 9px var(--line); }
.dev-top { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--marca); color: #0a0a0b; font: 600 15px var(--sans); letter-spacing: -.02em; }
.dev-id { min-width: 0; display: grid; }
.dev-id strong { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-id span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-canal { margin-left: auto; flex: none; font: 500 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 6px 9px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--marca) 55%, transparent); color: var(--marca); }
.msgs { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: 9px; padding: 16px; }
.msgs::-webkit-scrollbar { display: none; }
.b { max-width: 84%; padding: 9px 14px 10px; border-radius: 18px; font-size: 15px; line-height: 1.42; animation: rise .28s ease both; }
.b.a { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.b.c { align-self: flex-end; background: color-mix(in srgb, var(--marca) 26%, #17171a); border-bottom-right-radius: 6px; }
.b.p { align-self: flex-start; display: grid; gap: 4px; min-width: 230px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 16px; padding: 14px 16px; }
.b.p span { font-size: 13px; color: var(--muted); }
.b.p strong { font: 400 26px/1.1 var(--sans); letter-spacing: -.03em; }
.b.p strong small { font: 400 12px var(--mono); color: var(--muted); letter-spacing: .06em; margin-left: 5px; }
.b.p em { font-style: normal; font-size: 13px; font-weight: 500; margin-top: 8px; padding: 8px 12px; border-radius: 999px; text-align: center; background: var(--text); color: var(--bg); }
.b.dots { display: flex; gap: 4px; padding: 14px 16px; }
.b.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite; }
.b.dots i:nth-child(2) { animation-delay: .15s; }
.b.dots i:nth-child(3) { animation-delay: .3s; }

/* Piel de llamada */
.call { display: grid; justify-items: center; gap: 10px; padding: 22px 18px 14px; border-bottom: 1px solid var(--line); }
.orb { position: relative; width: 92px; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #15131f; box-shadow: 0 0 60px color-mix(in srgb, var(--marca) 30%, transparent), 0 0 0 1px rgba(255, 255, 255, .12) inset; }
.orb i { position: absolute; inset: -30%; filter: blur(12px); background: conic-gradient(from 0deg, #fff, var(--marca), #4a3ccf, #16184f, var(--marca), #fff); animation: spin 12s linear infinite; }
.orb::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .45), transparent 42%), radial-gradient(circle at 70% 85%, rgba(10, 10, 11, .55), transparent 55%); }
.timer { font: 400 15px var(--mono); color: var(--soft); font-variant-numeric: tabular-nums; }
.wave { display: flex; align-items: center; gap: 3px; width: 70%; height: 30px; }
.wave span { flex: 1; height: 100%; border-radius: 3px; background: var(--marca); transform: scaleY(.15); animation: wave 1.1s ease-in-out infinite; }
.device.en-pausa .wave span, .device.en-pausa .orb i { animation-play-state: paused; }
.device[data-canal="telefono"] .b { max-width: 92%; font-size: 14px; }
.device[data-canal="telefono"] .b::before { display: block; font: 400 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }
.device[data-canal="telefono"] .b.a::before { content: "Agente"; color: var(--marca); }
.device[data-canal="telefono"] .b.c::before { content: "Cliente"; }

/* Controles */
.controls { display: flex; align-items: center; gap: 8px; width: min(560px, 100%); padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.controls button { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; background: transparent; cursor: pointer; font-size: 15px; color: var(--soft); transition: background .2s; }
.controls button:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.controls .play { background: var(--text); color: var(--bg); }
.controls .play:hover { background: #fff; color: var(--bg); }
.controls #cVel { font: 500 12.5px var(--mono); }
.ctx { min-width: 0; margin-left: 6px; padding-right: 10px; font: 400 12px/1.35 var(--mono); letter-spacing: .03em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atajos { font: 400 11.5px var(--mono); letter-spacing: .04em; color: var(--dim); text-align: center; }

/* Panel del negocio */
.biz { border-left: 1px solid var(--line); background: var(--bg-2); padding: 22px 20px; display: grid; gap: 12px; align-content: start; }
.biz > .mono-label:not(:first-child) { margin-top: 14px; }
.integ { display: flex; flex-wrap: wrap; gap: 6px; }
.integ li { font-size: 13px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); display: flex; align-items: center; gap: 8px; transition: color .3s, border-color .3s, background .3s; }
.integ li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }
.integ li.on { color: var(--text); border-color: color-mix(in srgb, var(--marca) 55%, transparent); background: color-mix(in srgb, var(--marca) 12%, transparent); }
.integ li.on::before { background: var(--marca); opacity: 1; }
.integ li.pulso { animation: pulso .9s ease; }
.ficha div { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ficha dt { color: var(--dim); flex: none; }
.ficha dd { text-align: right; color: var(--soft); }
.ficha dd.flash { animation: flash 1.2s ease; }
.ficha dd.is-ok { color: var(--ok); }
.log { display: grid; gap: 10px; }
.log li { font-size: 13.5px; color: var(--muted); padding-left: 16px; position: relative; animation: rise .3s ease both; }
.log li::before { content: ""; position: absolute; left: 0; top: .55em; width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--marca); }
.log li:last-child { color: var(--text); }
.log li:last-child::before { background: var(--marca); }
.resultado { margin-top: 10px; padding: 16px; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 9%, transparent); display: grid; gap: 8px; animation: rise .4s ease both; }
.resultado .mono-label { color: var(--ok); }
.resultado p:last-child { font-size: 16px; line-height: 1.4; }
.vivo { margin-top: 14px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.vivo .btn { white-space: normal; text-align: center; }

/* Diálogo */
.dlg { border: 1px solid var(--line-2); border-radius: 22px; background: var(--panel); color: var(--text); padding: 28px; width: min(580px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(0, 0, 0, .65); }
.dlg form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dlg h2 { grid-column: 1 / -1; font: 400 25px/1.1 var(--sans); letter-spacing: -.03em; }
.dlg .full { grid-column: 1 / -1; }
.dlg label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }
.dlg .opt { color: var(--dim); }
.dlg input, .dlg select, .dlg textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); font-size: 15px; }
.dlg input[type="color"] { padding: 4px; height: 42px; }
.dlg select option { background: var(--panel); }
.dlg textarea { resize: vertical; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; }

/* Modo presentador: pantalla limpia para reuniones */
body.presentando .giros, body.presentando .top-title, body.presentando #bPersonalizar { display: none; }
body.presentando .studio { grid-template-columns: minmax(0, 1fr) 400px; }
body.presentando .device { height: clamp(460px, calc(100vh - 310px), 700px); }
body.presentando .atajos { color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes wave { 0%, 100% { transform: scaleY(.15); } 50% { transform: scaleY(var(--h, .8)); } }
@keyframes flash { 0% { color: var(--marca); } }
@keyframes pulso { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--marca) 55%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .wave span { transform: scaleY(var(--h, .6)); } }

@media (max-width: 1180px) {
  .studio { grid-template-columns: minmax(0, 1fr) 330px; }
  .giros { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; gap: 6px; padding: 10px 14px; scrollbar-width: none; }
  .giros::-webkit-scrollbar { display: none; }
  .giro { flex: none; grid-template-columns: 10px auto; padding: 8px 14px; border-radius: 999px; }
  .giro small { display: none; }
}
@media (max-width: 820px) {
  .top { flex-wrap: wrap; padding: 12px 14px; }
  .top-title { display: none; }
  .top-actions { margin-left: auto; }
  #bPersonalizar { order: 3; }
  #bPresentador, #bPantalla, .atajos { display: none; }
  .studio, body.presentando .studio { grid-template-columns: minmax(0, 1fr); }
  .stage { padding: 22px 14px 28px; }
  .device { height: 560px; border-radius: 30px; box-shadow: 0 40px 90px -50px #000, 0 0 0 5px #111113, 0 0 0 6px var(--line); }
  .biz { border-left: 0; border-top: 1px solid var(--line); }
  .dlg form { grid-template-columns: 1fr; }
  .ctx { white-space: normal; }
  .controls { border-radius: 22px; }
}
