:root {
  --fondo: #f6f4ee;
  --panel: #ffffff;
  --panel-2: #f0ede4;
  --borde: #e2ddd0;
  --texto: #1d1c19;
  --suave: #6b675c;
  --amarillo: #ffcf00;
  --amarillo-texto: #1d1c19;
  --azul: #1f6fd6;
  --verde: #1f9d55;
  --rojo: #d93a2b;
  --codigo-fondo: #1e1f24;
  --codigo-texto: #e8e6df;
  --sombra: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --radio: 14px;
  --letra: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #15161a;
    --panel: #1e2026;
    --panel-2: #262830;
    --borde: #33363f;
    --texto: #ecebe6;
    --suave: #a3a199;
    --azul: #5b9bf0;
    --verde: #3cc47a;
    --rojo: #f05a4a;
    --codigo-fondo: #101115;
    --sombra: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #15161a; --panel: #1e2026; --panel-2: #262830; --borde: #33363f; --texto: #ecebe6;
  --suave: #a3a199; --azul: #5b9bf0; --verde: #3cc47a; --rojo: #f05a4a; --codigo-fondo: #101115;
  --sombra: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 500 17px/1.45 var(--letra);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#i-play path, .probar svg, .grande svg[data-relleno] { fill: currentColor; }

/* Barra de arriba */
.barra {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--panel); border-bottom: 1px solid var(--borde);
}
.titulo { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.marca { font-weight: 800; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--suave); }
.experimento { all: unset; cursor: pointer; font-weight: 800; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icono { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; }
.icono:hover { background: var(--panel-2); }
.chip-robot {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px;
  border: 1px solid var(--borde); border-radius: 999px; background: var(--panel); font-weight: 700; white-space: nowrap;
}
.chip-robot .punto { width: 10px; height: 10px; border-radius: 50%; background: var(--suave); }
.chip-robot.conectado .punto { background: var(--verde); box-shadow: 0 0 0 4px color-mix(in srgb, var(--verde) 20%, transparent); }
.chip-robot.conectado svg { color: var(--azul); }
.parar {
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px;
  border: 0; border-radius: 999px; background: var(--rojo); color: #fff; font-weight: 800;
}
.parar svg { fill: #fff; stroke: none; }

/* Pestañas (sólo en pantallas angostas) */
.pestanas { display: none; gap: 6px; padding: 8px 16px 0; background: var(--fondo); }
.pestanas button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px;
  border: 1px solid var(--borde); border-radius: 12px; background: var(--panel); font-weight: 700; color: var(--suave);
}
.pestanas button.activa { background: var(--amarillo); color: var(--amarillo-texto); border-color: var(--amarillo); }

/* Taller: charla + programa */
.taller { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.lado { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.lado-pestanas { display: flex; gap: 6px; }
.lado-pestanas button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; position: relative;
  border: 1px solid var(--borde); border-radius: 12px; background: var(--panel); font-weight: 700; color: var(--suave);
}
.lado-pestanas button.activa, .pestanas button.activa { background: var(--amarillo); color: var(--amarillo-texto); border-color: var(--amarillo); }
.lado-pestanas svg, .pestanas svg { width: 18px; height: 18px; }
.punto-nuevo { position: absolute; top: 7px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--azul); }
.lado[data-lado="programa"] .pizarra, .lado[data-lado="pizarra"] .programa { display: none; }
.programa, .pizarra { flex: 1; }
.charla, .programa, .pizarra { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }

.transcripcion { flex: 1; overflow-y: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.vacio { margin: auto; text-align: center; color: var(--suave); max-width: 380px; }
.vacio svg { width: 56px; height: 56px; color: var(--amarillo); stroke-width: 1.6; }
.vacio .ideas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.vacio .ideas button { border: 1px solid var(--borde); background: var(--panel-2); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 15px; }

.msg-yo { align-self: flex-end; max-width: 85%; background: var(--amarillo); color: var(--amarillo-texto); padding: 10px 14px; border-radius: 18px 18px 4px 18px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-yo img { display: block; max-width: 220px; border-radius: 10px; margin-bottom: 6px; }
.msg-agente { max-width: 92%; overflow-wrap: anywhere; }
.msg-agente p { margin: 0 0 8px; }
.msg-agente p:last-child { margin-bottom: 0; }
.msg-agente ul, .msg-agente ol { margin: 4px 0 8px; padding-left: 22px; }
.msg-agente code { font-family: var(--mono); font-size: .88em; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.msg-agente pre, .paso pre { font-family: var(--mono); font-size: 13.5px; line-height: 1.5; background: var(--codigo-fondo); color: var(--codigo-texto); padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 6px 0; white-space: pre; }
.msg-agente pre code { background: none; padding: 0; }
.paso pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow-y: auto; }
.nota-agente { color: var(--suave); font-size: 15px; font-style: italic; }
.aviso-sistema { align-self: center; color: var(--suave); font-size: 14px; background: var(--panel-2); border-radius: 999px; padding: 4px 12px; text-align: center; }
.aviso-sistema.error { color: var(--rojo); }

.paso { border: 1px solid var(--borde); border-radius: 12px; background: var(--fondo); font-size: 15px; }
.paso > summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; list-style: none; font-weight: 700; }
.paso > summary::-webkit-details-marker { display: none; }
.paso > summary .que { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paso .ico { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--panel-2); }
.paso .ico svg { width: 18px; height: 18px; }
.paso.correr .ico { background: color-mix(in srgb, var(--azul) 16%, transparent); color: var(--azul); }
.paso.escribir .ico { background: color-mix(in srgb, var(--amarillo) 30%, transparent); }
.paso .estado { font-size: 13px; color: var(--suave); font-weight: 700; }
.paso .estado.ok { color: var(--verde); }
.paso .estado.mal { color: var(--rojo); }
.paso .detalle { padding: 0 12px 10px; }
.paso .detalle .rotulo { font-size: 12px; font-weight: 800; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.paso img { max-width: 100%; border-radius: 10px; margin-top: 6px; }
.girando { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--borde); border-top-color: var(--azul); animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.pensando { display: flex; align-items: center; gap: 10px; color: var(--suave); font-weight: 700; }

.redactor { border-top: 1px solid var(--borde); padding: 10px; background: var(--panel); }
.adjunto { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; color: var(--suave); }
.adjunto img { height: 48px; border-radius: 8px; }
.caja { display: flex; align-items: flex-end; gap: 6px; background: var(--fondo); border: 1px solid var(--borde); border-radius: 22px; padding: 4px; }
.caja textarea { flex: 1; border: 0; background: transparent; resize: none; font: inherit; color: inherit; padding: 10px 6px; max-height: 160px; outline: none; }
.mic.escuchando { background: var(--rojo); color: #fff; animation: latir 1.2s ease-in-out infinite; }
@keyframes latir { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--rojo) 25%, transparent); } }
.enviar { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--azul); color: #fff; display: grid; place-items: center; }
.enviar:disabled { opacity: .4; }

/* Programa */
.archivos-barra { display: flex; align-items: center; gap: 6px; padding: 8px 8px 0; border-bottom: 1px solid var(--borde); }
.archivos { flex: 1; display: flex; gap: 4px; overflow-x: auto; }
.archivos button { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 8px 12px; border-radius: 10px 10px 0 0; font-family: var(--mono); font-size: 14px; color: var(--suave); white-space: nowrap; }
.archivos button svg { width: 16px; height: 16px; }
.archivos button.activo { background: var(--codigo-fondo); color: var(--codigo-texto); }
.archivos button.cambio::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amarillo); }
.codigo { flex: 1.4; min-height: 120px; border: 0; resize: none; outline: none; padding: 12px 14px; background: var(--codigo-fondo); color: var(--codigo-texto); font: 15px/1.55 var(--mono); tab-size: 4; white-space: pre; overflow: auto; }
.consola-barra { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); border-top: 1px solid var(--borde); }
.probar { display: flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; background: var(--verde); color: #fff; padding: 8px 14px; font-weight: 800; font-size: 14px; text-transform: none; letter-spacing: 0; }
.probar svg { width: 16px; height: 16px; fill: #fff; stroke: none; }
.consola-botones { display: flex; gap: 8px; }
.hablar { display: flex; align-items: center; gap: 6px; border: 2px solid var(--rojo); border-radius: 999px; background: transparent; color: var(--rojo); padding: 6px 12px; font-weight: 800; font-size: 14px; text-transform: none; letter-spacing: 0; }
.hablar svg { width: 16px; height: 16px; }
.hablar.escuchando { background: var(--rojo); color: #fff; animation: latir 1.2s ease-in-out infinite; }
.hablar[hidden] { display: none; }
.consola { flex: 1; min-height: 70px; margin: 0; padding: 10px 14px; overflow: auto; background: var(--panel-2); font: 14px/1.5 var(--mono); white-space: pre-wrap; }

/* Paneles */
dialog.panel { border: 0; border-radius: 18px; padding: 18px; width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); background: var(--panel); color: var(--texto); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.panel::backdrop { background: rgba(10, 10, 12, .45); }
dialog h2 { font-size: 20px; margin: 4px 0 12px; }
.panel-cabeza { display: flex; align-items: center; justify-content: space-between; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 15px; margin: 10px 0; }
dialog input, dialog select { font: inherit; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; background: var(--fondo); color: inherit; }
.grande { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; border: 0; border-radius: 12px; background: var(--amarillo); color: var(--amarillo-texto); font-weight: 800; }
.secundario { width: 100%; padding: 11px; border: 1px solid var(--borde); border-radius: 12px; background: var(--panel); font-weight: 700; margin-top: 10px; }
.lista { list-style: none; padding: 0; margin: 10px 0; max-height: 40dvh; overflow: auto; }
.lista li { display: flex; align-items: center; gap: 6px; }
.lista li button.abrir { flex: 1; text-align: left; border: 0; background: transparent; padding: 10px; border-radius: 10px; }
.lista li button.abrir:hover, .lista li.actual button.abrir { background: var(--panel-2); }
.lista li small { display: block; color: var(--suave); font-size: 13px; }
.nota { color: var(--suave); font-size: 14px; }
.opcion-robot { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px; margin-bottom: 8px; border: 1px solid var(--borde); border-radius: 12px; background: var(--fondo); }
.opcion-robot strong { display: block; }
.opcion-robot small { color: var(--suave); }
.opcion-robot[disabled] { opacity: .55; }
/* Pizarra: dibujos de Claude Code e instrucciones oficiales */
.pizarra-lista { display: flex; gap: 6px; padding: 10px 10px 0; overflow-x: auto; flex-shrink: 0; }
.pizarra-lista button {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--borde); background: var(--panel-2); font-weight: 700; font-size: 14px; color: var(--suave);
}
.pizarra-lista button.activa { background: var(--codigo-fondo); color: var(--codigo-texto); border-color: var(--codigo-fondo); }
.pizarra-lista svg { width: 16px; height: 16px; }
.pizarra-vista { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 10px; background: #fff; margin: 10px; border-radius: 12px; border: 1px solid var(--borde); }
.pizarra-vista img, .pizarra-vista canvas { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.pizarra-vista.zoom { place-items: start; }
.pizarra-vista.zoom img, .pizarra-vista.zoom canvas { max-width: none; max-height: none; width: 200%; height: auto; }
.pizarra-vista .vacio { color: #6b675c; }
.pizarra-vista .cargando { color: #6b675c; font-weight: 700; }
.pizarra-nav { display: flex; align-items: center; gap: 8px; padding: 0 10px 10px; }
.pizarra-nav span { flex: 1; text-align: center; font-weight: 800; }
.pizarra-nav .icono:disabled { opacity: .35; }
.paso .dibujo { display: block; max-width: 100%; max-height: 260px; background: #fff; border-radius: 10px; border: 1px solid var(--borde); margin: 6px 0; cursor: zoom-in; }

.camara video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
.camara .pedido { font-weight: 800; margin: 0 0 10px; }
.camara .aviso, #clave .aviso { color: var(--rojo); font-size: 14px; }
.camara .acciones { display: flex; gap: 8px; }
.camara .acciones > * { flex: 1; margin: 0; }

@media (max-width: 899px) {
  .pestanas { display: flex; }
  .taller { grid-template-columns: 1fr; padding-top: 8px; }
  .lado-pestanas { display: none; }
  .taller[data-vista="charla"] .lado, .taller:not([data-vista="charla"]) .charla { display: none; }
  .chip-robot .texto { max-width: 26vw; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 520px) {
  .barra { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .marca { display: none; }
  .parar span, .chip-robot .texto { display: none; }
  .parar, .chip-robot { padding: 0 12px; }
}

/* Pizarra: recorte del manual, manual del invento y modelo 3D (sobre la pizarra blanca) */
.pz-texto { border: 1px solid var(--borde); background: var(--panel-2); color: var(--texto); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 13px; }
.pz-texto[hidden], #pz-imprimir[hidden] { display: none; }
.pizarra-lista button.tipo-invento svg { color: #ff7a00; }
.pizarra-lista button.tipo-modelo svg { color: var(--azul); }
.pizarra-vista canvas.modelo-3d { width: 100%; height: 100%; max-height: none; touch-action: none; cursor: grab; }
.pizarra-vista:has(> canvas.modelo-3d) { padding: 0; overflow: hidden; }
.manual { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 10px; color: #1d1c19; }
.manual-cabeza { display: flex; align-items: center; gap: 12px; }
.manual-cabeza h3 { margin: 0; font-size: 22px; }
.manual-num { flex-shrink: 0; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #ff7a00; color: #fff; font-weight: 900; font-size: 22px; }
.manual-imagen { flex: 1; min-height: 0; display: grid; place-items: center; }
.manual-imagen > img, .manual-imagen > canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.manual-imagen .caja-3d { width: 100%; height: 100%; min-height: 260px; }
.manual-texto { margin: 0; font-size: 18px; line-height: 1.45; }
.manual-portada { margin: auto; text-align: center; max-width: 520px; }
.manual-portada svg { width: 64px; height: 64px; color: #ff7a00; fill: #ffcf00; }
.manual-portada h2 { font-size: 30px; margin: 8px 0; }
.manual-autor { font-weight: 800; color: #6b675c; }
.manual-cuantos { color: #6b675c; font-size: 14px; }

/* Ideas para empezar */
.tarjetas-ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 12px 0; text-align: left; }
.idea { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 14px; border: 1px solid var(--borde); background: var(--panel); color: var(--texto); font-size: 14px; line-height: 1.35; }
.idea strong { font-size: 16px; }
.idea > span:last-child { color: var(--suave); }
.idea-nivel { align-self: flex-start; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--suave); }
.idea.nivel-1 .idea-nivel { background: color-mix(in srgb, var(--verde) 18%, transparent); color: var(--verde); }
.idea.nivel-2 .idea-nivel { background: color-mix(in srgb, var(--azul) 18%, transparent); color: var(--azul); }
.idea.nivel-3 .idea-nivel { background: color-mix(in srgb, #ff7a00 20%, transparent); color: #d46500; }
.vacio:has(.tarjetas-ideas) { max-width: 640px; }
.ver-ideas { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--azul); font-weight: 800; font-size: 15px; }
.ver-ideas svg { width: 18px; height: 18px; }

/* Mi taller */
dialog.panel.ancho { width: min(760px, calc(100vw - 32px)); }
.grande.secundario { background: var(--panel-2); color: var(--texto); margin-bottom: 8px; }
.mt-pestanas { display: flex; gap: 6px; margin: 10px 0; }
.mt-pestanas button { flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--borde); background: var(--panel-2); color: var(--suave); font-weight: 800; }
.mt-pestanas button.activa { background: var(--amarillo); color: var(--amarillo-texto); border-color: var(--amarillo); }
#mt-contenido h3 { margin: 16px 0 0; }
.mt-resumen { margin: 4px 0; }
.mt-exp { border: 1px solid var(--borde); border-radius: 14px; padding: 12px; margin: 10px 0; background: var(--fondo); }
.mt-titulo { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; width: 100%; border: 0; background: transparent; color: var(--texto); padding: 0; text-align: left; font-size: 16px; }
.mt-titulo small { color: var(--suave); flex-shrink: 0; }
.mt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mt-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--borde); font-size: 13px; font-weight: 700; color: var(--suave); }
.mt-chip svg { width: 14px; height: 14px; }
.mt-chip[role="button"] { cursor: pointer; color: var(--texto); border-color: #ff7a00; }

/* Impresión del manual del invento */
#impresion { display: none; }
@media print {
  body > *:not(#impresion) { display: none !important; }
  #impresion { display: block; color: #000; background: #fff; font-family: var(--letra); }
  #impresion header h1 { font-size: 30px; margin: 0 0 6px; }
  #impresion section { break-inside: avoid; page-break-inside: avoid; margin: 18px 0; }
  #impresion h2 { display: flex; align-items: center; gap: 10px; font-size: 20px; }
  #impresion h2 span { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #ff7a00; color: #fff; }
  #impresion .imagen img { max-width: 100%; max-height: 520px; display: block; margin: 0 auto; }
  #impresion pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; border: 1px solid #ccc; padding: 10px; border-radius: 8px; }
}
